<div class="panel panel-default">
	<div class="panel-heading">
	<?php 
		$this->widget('zii.widgets.CBreadcrumbs',array(
			'links'=>array(
					'后台管理',
					'属性列表'
			)
		));
		?>
	</div>
	<div class="panel-body">
	<?php if(is_array($attr)): ?>
		<div class="panel">
			<div class="panel-body">
			<p class="text-right">
				<a href="<?php echo $this->createUrl('attr/add');?>" class="btn btn-primary">添加属性</a>
			</p>
				<table class="table">
					<thead>
						<tr>
							<th>属性ID值</th>
							<th>属性名称</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody>
					<?php foreach($attr as $v):?>
						<tr>
							<td><?php echo $v->attr_id; ?></td>
							<td><?php echo $v->attr_name;?></td>
							<td>
								<a href="<?php echo $this->createUrl('edit',array('attrId'=>$v->attr_id));?>">编辑</a>
								<a class="delete" attrId="<?php echo $v->attr_id;?>" href="<?php echo $this->createUrl('delete');?>">删除</a>
							</td>
						</tr>
						<?php endforeach;?>
					</tbody>
				</table>
			</div>
		</div>
		<?php else:?>
		没有记录
		<?php endif;?>
	</div>
</div>
<script>
	$(function(){
		$('.delete').click(function(){
			var $this = $(this);
			if(!confirm("确定要删除吗？")){
				return false;
			}
			$.ajax({
				method : 'post',
				data : {'attrId' : $this.attr('attrId')},
				url : $this.attr('href'),
				success : function(data){
					console.log(data);
					var data = eval("("+data+")");
					if(data.code == 1){
						$this.parents('tr').remove();
					} else {
						alert(data.message);
					}
				}
			});
			return false;
		});
	});
</script>